package com.wry.im.utlis;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
 * <h1> 统一返回 <h1>
 *
 * @author wry
 * @since 2023/4/28 9:51
 */
@Data
@AllArgsConstructor
public class R<T> implements Serializable {

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 描述
     */
    private String msg;

    /**
     * 数据
     */
    private T data;

    public static <T>R<T> success(){
        return new R<>(200, "ok", null);
    }

    public static <T>R<T> success(T data){
        return new R<>(200, "ok", data);
    }

    public static <T>R<T> fail(String msg){
        return new R<>(-1, msg, null);
    }
}
